from django.contrib.gis import admin
from django.contrib.gis.maps.google import GoogleMap
from core.models import *

GMAP = GoogleMap()

class EventAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('title',)}

class ArgumentAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('title',)}

class IdentityAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('site',)}
    list_display = ('title','access_level_required','description')
    list_editable = ('access_level_required','description')

class OpinionAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('title',)}

class ProjectUpdateInline(admin.TabularInline):
    model=ProjectUpdate

class ProjectAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('title',) }
    inlines = (ProjectUpdateInline,)
    
class PlaceGoogleAdmin(admin.OSMGeoAdmin):
    prepopulated_fields = {'slug': ('title',) }
    extra_js = [GMAP.api_url + GMAP.key]
    map_template = 'gis/admin/google.html'

class ResumeAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('title',)}

class ControlledFileAdmin(admin.ModelAdmin):
    model=ControlledFile

admin.site.register(ControlledFile, ControlledFileAdmin)
admin.site.register(Project, ProjectAdmin)
admin.site.register(Argument, ArgumentAdmin)
admin.site.register(Opinion, OpinionAdmin)
admin.site.register(Event, EventAdmin)
admin.site.register(Place, PlaceGoogleAdmin)
admin.site.register(ResumeEntry, ResumeAdmin)
admin.site.register(Identity, IdentityAdmin)
